import axios from 'axios'

const api = axios.create({
  baseURL: 'http://127.0.0.1:8000',
  withCredentials: true  // 允许携带cookie
})

// 获取图片验证码
export const getImageCaptcha = () => {
  return api.get('/image/', { responseType: 'blob' })
}

// 验证图片验证码
export const verifyImageCaptcha = (code) => {
  return api.post('/image/', { captcha: code })
}

// 发送短信验证码
export const sendSmsCode = (phone) => {
  return api.post('/code/', { phone })
}

// 登录
export const login = (phone, password, code) => {
  return api.post('/login/', { phone, password, code })
}

export default api